<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加会员</title>
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/homePage.css">
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/mobiscroll.custom-3.0.0-beta6.min.css"/>
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/flexible.js"></script>
    <script src="js/mobiscroll.custom-3.0.0-beta6.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/MD5.js"></script>
    <script src="js/qs.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/vant.js"></script>
</head>
<body>
<div id="apps">
    <div class="container_box" >
        <div class="Information_entry">
            <label class="lf">姓名</label>
            <div class="rf message padding14">
                <input v-model="from.Username" placeholder="请输入会员姓名">
            </div>
        </div>
        <div class="Information_entry">
            <label class="lf">电话</label>
            <div class="rf message padding14">
                <input v-model="from.Phone" oninput="value=value.replace(/[^\d]/g,'')" maxlength="11" type="text" placeholder="请输入会员手机号码">
            </div>
        </div>
            <p class="hint">作为手机端登录账号，请谨慎添加</p>
        <div class="Information_entry">
            <label class="lf">性别</label>
            <div class="rf sex padding14">
                <label><input type="radio" name="x1" value="1" @click="getRadioVal">男</label>
                <label><input type="radio" name="x1" value="0" @click="getRadioVal">女</label>
            </div>    
        </div>
        <div class="Information_entry">
            <label class="lf">出生日期</label>
            <div class="rf message padding14">
                <input ref="Birth"  type="text" id="age" placeholder="请选择出生日期">
            </div>
        </div>
        <div class="Information_entry">
            <label class="lf">来源</label>
            <div class="rf message padding14">
                <select v-model="from.Userfrom">
                    <option v-for="item in custofrom" :value="item.id">
                        {{item.Fromname}}
                    </option>
                </select>
            </div>
        </div>
        <div class="Information_entry">
            <label class="lf">会籍顾问</label>
            <div class="rf message padding14">
                <select v-model="from.Sale">
     <option style="display:none" value="" disabled>请选择</option>
                    <option v-for="item in Sale" :value="item.id">
                        {{item.Sname}}
                    </option>
                </select>
            </div>
        </div>
        <!-- <div class="remark">
            <label class="lf">备注</label>
            <div class="lf width75">
                <textarea v-model="from.Phone" rows="6" placeholder="请输入备注信息"></textarea>
            </div>
        </div> -->
        <div class="save" @click="save">
            <button type="button">提交</button>
        </div>
    </div>
</div>
</body>
<script>
new Vue({
    el: '#apps',
    data: {
        type:'0',
        list:[],
        from:{
            Username: '',
            Phone:'',
            Sex:'1',
            Userfrom:"",
            Birth:"",
            Sale:""
        },
        custofrom:[],
        Sale:[],
        timersss:''
    },
    created(){
        this.getList()
    },
    methods:{
        getRadioVal (event) { 
            let radioVal = event.target.value;  
            console.log(radioVal);
            this.from.Sex=radioVal
        },
        //获取信息
        getList(){
            getVs()
            axios.get('/mobileapi/adviser/user.php?act=staff_from').then(data =>{
                console.log(data.data)
                let { msg, code,user} = data.data
                    if (code !== 200) {
                        window.vant.Toast.fail(msg)
                    } else {
                        data=data.data
                        this.custofrom=data.data.custofrom
                        this.Sale=data.data.staff
                    }
                }).catch(function (error) { 
                    console.log(error); 
            });
        },
        save(){
            this.from.Birth=this.$refs.Birth.value
            console.log(this.from)
            let from =JSON.stringify(this.from)
            let sign=md5(from)
            let params={
                from:from,
                sign:sign
            }
            getVs()
            axios.post('/mobileapi/adviser/user.php?act=member_add',
            Qs.stringify(params)).then(function(response){
                console.log(response.data)
                let { msg, code} = response.data
                    if (code !== 200) {
                        window.vant.Toast.fail(msg)
                    } else {
                        var data = response.data
                        console.log(data)
                        window.vant.Toast.success('添加成功')
                        setTimeout(function(){
                            let type="0"
                            let state='1'
                            window.location.href='myMember.html?type='+type+'&state='+state+''
                        }, 2000);
                    }
                    
                }).catch(function (error) { 
                    console.log(error); 
            });
        }
    },
})
//日期插件
$('#age').mobiscroll().date({
    theme: 'mobiscroll',
    display: 'bottom',
    lang: 'zh',
    defaultValue:new Date('1990-06-15'),
    dateFormat: 'yy-mm-dd',
    startYear:1940,
    endYear:2019,
});
</script>
</html>